package com.sca.bussiness.service.impl;

import com.sca.bussiness.job.OrderCancelJob;
import com.sca.bussiness.service.BussinessService;
import com.sca.bussiness.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @author liuxianfei
 * @since 2020/11/20 12:21
 */
@Slf4j
@Service
public class BussinessServiceImpl implements BussinessService {

    private final ScheduleService scheduleService;

    public BussinessServiceImpl(ScheduleService scheduleService) {
        this.scheduleService = scheduleService;
    }

    @Override
    public Boolean testTimerJob() {
        OrderCancelJob orderCancel = new OrderCancelJob();
        HashMap<String, Serializable> params = new HashMap<>();
        params.put("orderId", 1);
        orderCancel.setParams(params);
        scheduleService.addTimer(10L, orderCancel);
        return true;
    }

}
